<template>
  <a-card :loading="loading" :bordered="false">
    <a-row type="flex" justify="end">
      <a-button v-show="printModel" key="print" v-print="pdfConf">
          导出pdf
      </a-button>
    </a-row>
    <!-- 业务表单 -->
    <a-form-model ref="form" id="HonorTabel" :form="form" :model="formData" :rules="rules" style="margin-top: 8px">
      <h2 style="text-align:center;" ref='title'>广东培正学院{{currentPeriod}}年度共青团优秀个人申报表</h2>
      
      <table  le class="MsoNormalTable" border="1" cellspacing="0" style='font-family:"font-size:10pt;width:100%;'>
        <tbody>
          <tr>
            <td width="67" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">姓名</span>
              </p>
            </td>
            <td width="76" valign="top">
              <p class="18">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{
                  formData.creatorName
                }}</span>
                <a-form-model-item prop="creatorId" v-else>
                  <x-select-user-by-dep
                    v-model="formData.creatorId"
                    :triggerChange="true"
                    :searchIcon="true"
                    :disabled="!editable || editableFiexd['creatorId']"
                    :multi="false"
                    @selected="selectUser"
                  ></x-select-user-by-dep>
                </a-form-model-item>
              </p>
            </td>
            <td width="61" valign="top">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">性别</span>
              </p>
            </td>
            <td width="88" valign="top" colspan="2">
              <p class="18" align="center" style="text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.sex==2?"女":"男" }}</span>
                <a-form-model-item prop="sex" v-else>
                  <a-select
                    placeholder="请选择性别"
                    :disabled="!editable || editableFiexd['sex']"
                    v-model="formData.sex"
                  >
                    <a-select-option :value="1">男</a-select-option>
                    <a-select-option :value="2">女</a-select-option>
                  </a-select>
                </a-form-model-item>
              </p>
            </td>
            <td width="59" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">学号</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="109" valign="top">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.stdNo }}</span>
                <a-form-model-item prop="stdNo" v-else>
                  <a-input
                    :disabled="!editable || editableFiexd['stdNo']"
                    placeholder=""
                    v-model="formData.stdNo"
                  />
                </a-form-model-item>
              </p>
            </td>
          </tr>
          <tr>
            <td width="67" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">学院</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="76" valign="top">
              <p class="18" style="text-indent:0pt;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.college }}</span>
                <a-form-model-item prop="college" v-else>
                  <a-input
                    placeholder=""
                    :disabled="!editable || editableFiexd['college']"
                    v-model="formData.college"
                  />
                </a-form-model-item>
              </p>
            </td>
            <td width="61" valign="top">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">专业</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="88" valign="top" colspan="2">
              <p class="18" style="text-indent:0pt;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.major }}</span>
                <a-form-model-item prop="major" v-else>
                  <a-input
                    placeholder=""
                    :disabled="!editable || editableFiexd['major']"
                    v-model="formData.major"
                  />
                </a-form-model-item>
              </p>
            </td>
            <td width="59" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">班级</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="109" valign="top">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.clazz }}</span>
                <a-form-model-item prop="clazz" v-else>
                  <a-input
                    placeholder=""
                    :disabled="!editable || editableFiexd['clazz']"
                    v-model="formData.clazz"
                  />
                </a-form-model-item>
              </p>
            </td>
          </tr>
          <tr>
            <td width="67" valign="top" colspan="2">
              <p class="18" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">政治面貌</span>
              </p>
            </td>
            <td width="76" valign="top">
              <p class="18">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{
                  politicalFilter(formData.politicalStatus)
                }}</span>
                <a-form-model-item prop="politicalStatus" v-else>
                  <j-dict-select-tag
                    :disabled="!editable || editableFiexd['politicalStatus']"
                    v-model="formData.politicalStatus"
                    dictCode="political_outlook"
                  />
                </a-form-model-item>
              </p>
            </td>
            <td width="149" valign="top" colspan="3">
              <p class="18" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">所担任的职务</span>
              </p>
            </td>
            <td width="169" valign="top" colspan="3">
              <p class="18">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.post }}</span>
                <a-form-model-item prop="post" v-else>
                  <a-input
                    placeholder=""
                    :maxLength="20"
                    :disabled="!editable || editableFiexd['post']"
                    v-model="formData.post"
                  />
                </a-form-model-item>
              </p>
            </td>
          </tr>
          <tr>
            <td width="144" valign="center" colspan="3">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">申报奖项</span
                ><span style="font-family:仿宋_GB2312;font-size:10.5pt;"></span>
              </p>
            </td>
            <td width="319" valign="center" colspan="6">
              <div v-if="browseMode" style="display:flex;align-items:center;min-height: 6em;">
                <dl class="MsoNormalDL" style='font-family:"font-size:10.5pt;'>
                  <dd v-for="(item,key) in gloryDictOptions" :key="key">
                    <span style="font-family:仿宋_GB2312;font-size:12pt;"  >{{item.text}}</span
                    >
                    <!-- <span style="font-family:Wingdings;font-size:12pt;">{{formData.glory== item.value?'þ':'¨'}}</span
                    > -->
                    <a-icon type="check-square" v-if="formData.glory== item.value"/>
                    <a-icon type="border" v-else/>
                  </dd>
                </dl>
              </div>
              <a-form-model-item prop="glory" v-else>
                <j-dict-select-tag
                  type="radio"
                  v-model="formData.glory"
                  :disabled="!editable || editableFiexd['glory']"
                  dictCode="honor_list"
                />
              </a-form-model-item>
            </td>
          </tr>
          <tr>
            <td width="45" valign="center" rowspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">GPA值</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="99" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">{{lastPeriod+"-2学期"}}</span>
              </p>
            </td>
            <td width="61" valign="top">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.gpaB }}</span>
                <a-form-model-item prop="gpaB" v-else>
                  <a-input
                    placeholder=""
                    
                    v-model="formData.gpaB"
                  />
                </a-form-model-item>
              </p>
            </td>
            <td width="58" valign="center" rowspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">综合测评排名百分比</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="87" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">{{lastPeriod+"-2学期"}}</span>
              </p>
            </td>
            <td width="112" valign="top" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{
                  formData.evaluatioRankingB + "%"
                }}</span>
                <a-form-model-item prop="evaluatioRankingB" v-else>
                  <a-input-number v-model="formData.evaluatioRankingB" :disabled="!editable || editableFiexd['evaluatioRankingB']"
                     :min="0" :max="100" :formatter="value => `${value}%`" :parser="value => value.replace('%', '')" />
    
                </a-form-model-item>
              </p>
            </td>
          </tr>
          <tr>
            <td width="99" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">{{currentPeriod+"-1学期"}}</span>
              </p>
            </td>
            <td width="61" valign="top">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{ formData.gpaA }}</span>
                <a-form-model-item prop="gpaA" v-else>
                  <a-input
                    placeholder=""
                    
                    v-model="formData.gpaA"
                  />
                </a-form-model-item>
              </p>
            </td>
            <td width="87" valign="top" colspan="2">
              <p class="18" align="center" style="text-indent:0pt;text-align:center;">
                <span style="font-family:仿宋_GB2312;font-size:12pt;">{{currentPeriod+"-1学期"}}</span>
              </p>
            </td>
            <td width="112" valign="top" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;" v-if="browseMode">{{
                  formData.evaluatioRankingA +'%'
                }}</span>
                <a-form-model-item prop="evaluatioRankingA" v-else>
                  <a-input-number v-model="formData.evaluatioRankingA" :disabled="!editable || editableFiexd['evaluatioRankingA']"
                     :min="0" :max="100" :formatter="value => `${value}%`" :parser="value => value.replace('%', '')" />
    
                </a-form-model-item>
              </p>
            </td>
          </tr>
          <tr>
            <td width="67" valign="center" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">个人总结</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="395" valign="top" colspan="7">
              <p class="MsoNormal" style='text-align:justify;font-family:"font-size:10.5pt;background:#FFFFFF;' v-if="formData.glory=='wshqqn'||formData.glory=='sjtzbsj'">
                <b><span style="font-family:仿宋_GB2312;font-size:12pt;">参评</span></b
                ><b><span style="font-family:仿宋_GB2312;font-size:12pt;">五四红旗青年</span></b
                ><b><span style="font-family:仿宋_GB2312;font-size:12pt;">、</span></b
                ><b><span style="font-family:仿宋_GB2312;font-size:12pt;">十佳团支部书记</span></b
                ><b><span style="font-family:仿宋_GB2312;font-size:12pt;">需附1200字左右事迹材料</span></b
                ><b><span style="font-family:Arial;color:#333333;font-size:12pt;"></span></b>
                <!-- 上传附件 -->
                <a-form-item label="附件" :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" v-if="!browseMode">
                  <j-upload :disabled="!editable || editableFiexd['enclosures']" v-model="formData.enclosures" text="上传文件" bizPath="honor"></j-upload>
                </a-form-item>
              </p>
              <p class="MsoNormal" style='text-align:justify;font-family:"font-size:10.5pt;background:#FFFFFF;'>
                <span style="font-family:宋体;color:#333333;font-size:12pt;">&nbsp;</span>
              </p>
              <div class="MsoNormal">
                <div v-if="browseMode" v-html="formData.personalSummary||''"></div>
                <a-form-model-item prop="personalSummary" v-else>
                  <j-editor 
                    :disabled="!editable || editableFiexd['personalSummary']"
                    v-model="formData.personalSummary"
                  />
                </a-form-model-item>
              </div>
            </td>
          </tr>
          <tr>
            <td width="67" valign="center" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">获 &nbsp;&nbsp;奖</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">情 &nbsp;&nbsp;况</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="395" valign="top" colspan="7">
              <div class="MsoNormal">
                <div v-if="browseMode" v-html="formData.awards||''"></div>
                <a-form-model-item prop="awards" v-else style="min-height: 210px">
                  <j-editor 
                    :disabled="!editable || editableFiexd['awards']"
                    v-model="formData.awards"
                  />
                </a-form-model-item>
              </div>
            </td>
          </tr>
          <tr>
            <td width="67" valign="center" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">辅导员或</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">指导老师意</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">&nbsp;&nbsp;&nbsp;</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">见</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="395" valign="top" colspan="7">
              <!-- 指导老师 -->
              <a-form-model-item prop="instructorId" v-if="!browseMode" :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="指导老师">
                <x-select-user-by-dep
                  v-model="formData.instructorId"
                  userType="teacher"
                  :disabled="!editable||editableFiexd['instructorId']"
                  :multi="false" @selected="setInstructor"></x-select-user-by-dep>
              </a-form-model-item>
              <div
                class="MsoNormal"
                style='display:block;min-height:5em;text-align:justify;font-family:"font-size:10.5pt;'
              >
                <div style="font-family:仿宋_GB2312;font-size:12pt;" v-html="task1.opinion"></div>
              </div>
              <p
                class="MsoNormal"
                style='text-align:justify;line-height: 2.5;font-family:"font-size:10.5pt;text-indent:60%;'
              >
                <span style="font-family:仿宋_GB2312;font-size:12pt;">签 &nbsp;名:&nbsp;{{task1.dealUserName}}</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p
                class="MsoNormal"
                style='text-align:justify;line-height: 2.5;font-family:"font-size:10.5pt;text-indent:65%;'
              >
                <span style="font-family:仿宋_GB2312;font-size:12pt;"
                  >{{task1.dealTime? moment(task1.dealTime).format('&nbsp;&nbsp;yyyy&nbsp;年&nbsp;&nbsp;MM&nbsp;月&nbsp;&nbsp;DD&nbsp;日'):'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日'}}</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
          </tr>
          <tr>
            <td width="67" valign="center" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">学院</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">团委</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">意</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">&nbsp;&nbsp;&nbsp;</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">见</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="395" valign="top" colspan="7">
              <div
                class="MsoNormal"
                style='display:block;min-height:5em;text-align:justify;font-family:"font-size:10.5pt;'
              >
                <div style="font-family:仿宋_GB2312;font-size:12pt;" v-html="task2.opinion"></div>
              </div>
              <p
                class="MsoNormal"
                style='text-align:justify;line-height: 2.5;font-family:"font-size:10.5pt;text-indent:60%;'
              >
                <span style="font-family:仿宋_GB2312;font-size:12pt;">签 &nbsp;名（盖章）:&nbsp;{{task2.dealUserName}}</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p
                class="MsoNormal"
                style='text-align:justify;line-height: 2.5;font-family:"font-size:10.5pt;text-indent:65%;'
              >
                <span style="font-family:仿宋_GB2312;font-size:12pt;"
                  >{{task2.dealTime? moment(task2.dealTime).format('&nbsp;&nbsp;yyyy&nbsp;年&nbsp;&nbsp;MM&nbsp;月&nbsp;&nbsp;DD&nbsp;日'):'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日'}}</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
          </tr>
          <tr>
            <td width="67" valign="center" colspan="2">
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">学校团委</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p class="MsoNormal" align="center" style='text-align:center;font-family:"font-size:10.5pt;'>
                <span style="font-family:仿宋_GB2312;font-size:12pt;">意</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">&nbsp;&nbsp;&nbsp;</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;">见</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
            <td width="395" valign="top" colspan="7">
              <div
                class="MsoNormal"
                style='display:block;min-height:5em;text-align:justify;font-family:"font-size:10.5pt;'
              >
                <div style="font-family:仿宋_GB2312;font-size:12pt;" v-html="task3.opinion"></div>
              </div>
              <p
                class="MsoNormal"
                style='text-align:justify;line-height: 2.5;font-family:"font-size:10.5pt;text-indent:60%;'
              >
                <span style="font-family:仿宋_GB2312;font-size:12pt;">签 &nbsp;名（盖章）: &nbsp;{{task3.dealUserName}}</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
              <p
                class="MsoNormal"
                style='text-align:justify;line-height: 2.5;font-family:"font-size:10.5pt;text-indent:65%;'
              >
                <span style="font-family:仿宋_GB2312;font-size:12pt;"
                  >{{task3.dealTime? moment(task3.dealTime).format('&nbsp;&nbsp;yyyy&nbsp;年&nbsp;&nbsp;MM&nbsp;月&nbsp;&nbsp;DD&nbsp;日'):'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日'}}</span
                ><span style="font-family:仿宋_GB2312;font-size:12pt;"></span>
              </p>
            </td>
          </tr>
        </tbody>
      </table>
      <span style="display:none;" id="__kindeditor_bookmark_start_3__"></span>
    </a-form-model>
  </a-card>
</template>

<script>
import JDate from '@/components/jeecg/JDate.vue'
import JUpload from '@/components/jeecg/JUpload'
import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
import JSelectMultiUser from '@/components/jeecgbiz/JSelectMultiUser'
import XSelectUserByDep from '@/components/extends/XSelectUserByDep'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import { httpAction, getAction } from '@/api/manage'
import { merge } from 'lodash'
import JEditor from '@/components/jeecg/JEditor'
import moment from 'moment'
import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'
export default {
  name: 'HonorForm',
  components: {
    JDate,
    JEditor,
    JUpload,
    JSelectDepart,
    JDictSelectTag,
    JSelectMultiUser,
    XSelectUserByDep,
  },
  model: {
    prop: 'data',
    event: 'onchange'
  },
  props: {
    dataId: String,
    data: {
      type: Object,
      default: () => {
        return {}
      }
    },
    browseMode: Boolean,
    printModel: Boolean,
    editable: {
      type: Boolean,
      default: true
    },
    editableFiexd: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      moment,
      loading: true, //数据加载
      url: {
        add: '/gloryApply/add',
        edit: '/gloryApply/add',
        queryById: '/gloryApply/queryById',
        gpa:'/gpa/list'
      },
      form: this.$form.createForm(this), //表单
      formInited: false,
      formData: {
        period:'',
      }, //数据
      politicalDictOptions: [],
      gloryDictOptions:[],
      periodDictOptions:[],
      rules:{
        enclosures:[{ required: true, message: '请上传附件资料！', trigger: 'change'}],
        period:[{ required: true, message: '请选择学年！', trigger: 'change'}],
        creatorId:[{ required: true, message: '请选择学生！', trigger: 'change' }],
        sex:[{ required: true, message: '请选择性别！' , trigger: 'blur'}],
        stdNo:[{ required: true, message: '请输入学号' , trigger: 'blur'}],
        clazz:[{ required: true, message: '请输入班级' , trigger: 'blur'}],
        college:[{ required: true, message: '请输入学院' , trigger: 'blur'}],
        major:[{ required: true, message: '请输入专业' , trigger: 'blur'}],
        politicalStatus:[{ required: true, message: '请选择政治面貌' , trigger: 'blur'}],
        post:[{ required: true, message: '请输入所担任的职务' , trigger: 'blur'}],
        glory:[{ required: true, message: '请选择申报奖项' , trigger: 'blur'}],
        gpaA:[{ required: true, message: '请输入gpa成绩' , trigger: 'blur'}],
        gpaB:[{ required: true, message: '请输入gpa成绩' , trigger: 'blur'}],
        evaluatioRankingA:[{ required: true, message: '请输入综合测评排名百分比' , trigger: 'blur'}],
        evaluatioRankingB:[{ required: true, message: '请输入综合测评排名百分比' , trigger: 'blur'}],
        personalSummary:[{ required: true, message: '个人总结不能为空' , trigger: 'blur'}],
        awards:[{ required: true, message: '获奖情况不能为空' , trigger: 'blur'}],
        instructorId:[{ required: true, message: '请选择指导老师' , trigger: 'change'}],
      },
      pdfConf:{
          id:'HonorTabel',
          popTitle: '广东培正学院',
          beforeOpenCallback (vue) {
              vue.title = document.title
              document.title = vue.$refs.title.innerHTML
          },
          closeCallback (vue) {
              document.title = vue.title
          }
      }
    }
  },
  watch: {
    dataId(nv) {
      if (nv) {
        this.getData(nv)
      }
    },
    data: {
      handler(nv, ov) {
        this.formData = nv?Object.assign(this.formData,nv):{}
      },
      immediate: true,
      deep: true
    },
    formData: {
      handler(nv, ov) {
        this.$emit('onchange', nv)
      },
      immediate: true,
      deep: true
    }
  },
  computed:{
    currentPeriod(){
      let period = this.formData.period||this.moment().format('yyyy')
      let last = parseInt(period) - 1
      return last + '-' + period
    },
    lastPeriod(){
      let period = this.formData.period||this.moment().format('yyyy')
      period = parseInt(period) - 1
      let last = period - 1
      return last + '-' + period
    },
    task1(){
      if(this.formData&&this.formData.approveRecords){
        return this.formData.approveRecords[0]||{}
      }else{
        return {}
      }
    },
    task2(){
      if(this.formData&&this.formData.approveRecords){
        return this.formData.approveRecords[1]||{}
      }else{
        return {}
      }

    },
    task3(){
      if(this.formData&&this.formData.approveRecords){
        return this.formData.approveRecords[2]||{}
      }else{
        return {}
      }
    }
  },
  created() {
    // this.form.resetFields()
    this.initDictConfig()
    if (this.dataId) {
      this.getData(this.dataId)
    }
  },
  methods: {
    initDictConfig() {
      //初始化字典 
      // initDictOptions('periods').then(res => {
      //   if (res.success) {
      //     this.periodDictOptions = res.result
      //   }
      // })
      initDictOptions('political_outlook').then(res => {
        if (res.success) {
          this.politicalDictOptions = res.result
        }
      })
      initDictOptions('honor_list').then(res => {
        if (res.success) {
          this.gloryDictOptions = res.result
        }
      })
    },
    getGpa(params){
      return getAction(this.url.gpa,{xh:params.stdNo,xn:params.period})
    },
    periodFilter(value) {
      return filterDictText(this.periodDictOptions, value)
    },
    politicalFilter(value) {
      return filterDictText(this.politicalDictOptions, value)
    },
    selectUser(data) {
      let rows = data.rows
      if (Array.isArray(rows) && rows[0]) {
        let obj = {
          name: rows[0].realname,
          creatorName: rows[0].realname,
          college: rows[0].college,
          major: rows[0].major,
          clazz: rows[0].clazz,
          stdNo: rows[0].stdNo,
          sex: rows[0].sex
        }
        let temp = {}
        if(this.formData.creatorId&&this.formData.creatorName==obj.creatorName){
          for(let k of Object.keys(obj)){
            if(obj[k]){
              temp[k] = obj[k]
            }
          }
        }else{
          temp = obj
        }
        this.formData = Object.assign({},this.formData,temp)

        // 当前年度
        this.getGpa({
          stdNo: obj.stdNo,
          period: this.currentPeriod
        }).then(res=>{
          if(res.success&&res.result.length){
            let current = res.result[0]
            this.$nextTick(()=>{
              this.$set(this.formData,'gpaB',current.gpa1)
            })
          }
        })

        // 前年年度
        this.getGpa({
          stdNo: obj.stdNo,
          period: this.lastPeriod
        }).then(res=>{
          if(res.success&&res.result.length){
            let last = res.result[0]
            this.$nextTick(()=>{
              this.$set(this.formData,'gpaA',last.gpa2)
            })
          }
        })
      }
    },
    add(data) {
      this.loading = false
      this.open(data)
    },
    edit(record) {
      this.open(record)
    },
    open(record) {
      merge(this.formData,record,{})
      if (this.formData.id) {
        this.getData(record.id)
      }
    },
    getData(id) {
      this.loading = true
      getAction(this.url.queryById, { id })
        .then(res => {
          this.loading = false
          this.formData = Object.assign(this.formData,res.result || {})
        })
        .finally(() => {
          this.loading = false
        })
    },
    setInstructor(data){
      if(this.formData) this.formData.instructor = data.name
    },
    submitForm() {
      const that = this
      return new Promise((resolve, reject) => {
        // 触发表单验证
        that.$refs.form.validate((valid, Field) => {
          if (valid) {
            let httpurl = ''
            let method = ''
            if (!that.formData.id) {
              httpurl += that.url.add
              method = 'post'
            } else {
              httpurl += that.url.add
              method = 'post'
            }
            let formData = merge({}, that.formData)
            formData.period = this.currentPeriod
            httpAction(httpurl, formData, method)
              .then(res => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.$emit('ok')
                  resolve(res)
                } else {
                  that.$message.warning(res.message)
                  reject(res.message)
                }
              })
              .finally(() => {
                that.loading = false
              })
          } else {
            that.$message.warning('校验失败，请检查表单内容！')
            reject(Field)
          }
        })
      })
    }
  }
}
</script>

<style scoped>
table {
  width: 100%;
  table-layout: fixed;
}
table td {
  padding: 5px;
  line-height: 1.6;
  display: table-cell;
  vertical-align: middle;
}
p {
  line-height: 1.6;
  margin: 0;
}
.MsoNormalDL{
  display: inline-block;
  margin: 0;
}
.MsoNormalDL dd{
  margin: 0;
  width: 50%;
  display: inline-block;
  padding-left: 5em;
  vertical-align: middle;
}
</style>
